package com.liang.service;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect //声明这个类是一个切面
public class AnotationAop {
//    前置
    @Before("execution(* com.liang.service.UserServiceImpl.*(..))")
    public void beforeLog(){
        System.out.println("打印日志之前");
    }
//    后置返回
    @AfterReturning("execution(* com.liang.service.UserServiceImpl.*(..))")
    public String afterLog(){
        System.out.println("打印日志之后");
        return "日志打印后返回";
    }
//    环绕
    @Around("execution(* com.liang.service.UserServiceImpl.*(..))")
    public void round(ProceedingJoinPoint jp) throws Throwable {
        System.out.println("环绕前");
        jp.proceed();
        System.out.println("环绕后");
    }
}
